package drds.configuration.db.xml_mapping.dynamic_tag.xml_node;

import drds.configuration.db.xml_mapping.dynamic_tag.token_handler.TokenHandler;

import java.util.Properties;

public class GlobalVariableReplacementHandler implements TokenHandler {
    private final Properties variables;

    public GlobalVariableReplacementHandler(Properties variables) {
        this.variables = variables;
    }

    @Override
    public String handleToken(String key) {
        if (variables != null) {
            if (variables.containsKey(key)) {
                return variables.getProperty(key);
            }
        }
        return "${" + key + "}";//keep
    }
}
